using System;
using System.Collections.Generic;
using System.Text;
using TypeDataset;

namespace DataAccessor
{
    public enum COUNTRY
    {
        China,
        Japanese,
        Keroa,
        USA,
        Italy,
        UK,
        UNKnow
    }
    public enum TYPE
    {
        TypeA,
        TypeB,
        TypeC,
        UNKnow
    }
	public class MaskQCondition
	{
		public MaskQCondition(MaskNagivationNode viewNode)
		{
			NodeField = viewNode.FieldName;
			_FieldType = viewNode.FieldType;

			FieldValue = viewNode.FieldValue;
		}
		public MaskQCondition()
		{
			NodeField = "";
			_Value = "";
			_FieldType = "";
		}
		private string _FieldType;
		public string NodeField;
		private string _Value;
		public string FieldValue
		{
			get {
				return _Value;
			}
			set 
			{
				if (_FieldType == "string")
					_Value = string.Format("'{0}'", value);
				else
					_Value = value;
			}
		}
	}
    public interface IMaskQuery
    {
        MaskMainView.BaseMaskViewDataTable GetMaskView(MaskQCondition condition);
    }
    internal class MaskInfoQuery : IMaskQuery
    {
		private DBConnectionService _DBService = DBConnectionService.Instance();

	public MaskMainView.BaseMaskViewDataTable GetMaskView(MaskQCondition condition)
	{
		string sql;
		if (condition.NodeField == null || condition.NodeField == "")
			sql = "select * from maskview";
		else
			sql = string.Format("select * from maskview where {0} = {1}", condition.NodeField, condition.FieldValue);
		MaskMainView.BaseMaskViewDataTable table = _DBService.GetMaskViewTable(sql);
		return table;
	}
    }
}
